package com.laich.springcloud.order.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

import com.laich.springcloud.entity.User;
import com.laich.springcloud.feign.RemoteUserService;

@Controller
public class OrderController {

	@Autowired
	RemoteUserService remoteUserService;

	@GetMapping("/getUser/{id}")
	@ResponseBody
	public User getUser(@PathVariable String id) {
		// for debug
		return remoteUserService.getUser(id);
	}

	@GetMapping("/order/{id}")
	@ResponseBody
	public String getOrder(@PathVariable String id) {
		// for debug
		return "order id : " + id;
	}

	@GetMapping("/orderUser/{username}")
	@ResponseBody
	public User orderUser(@PathVariable String username) {
		// for debug
		User user = remoteUserService.findByUserName(username);
		return user;
	}

	@GetMapping("/list")
	public String list() {
		return "order/list";
	}
}
